<style>
    #creation_steps{
        padding: 10px;
        text-align: center;
    }
    #steps_number{
        margin-bottom: 5px;
        padding: 0px 10%;
    }
    #steps_number span{
        display: inline-block;
        width: 33%;
        height: 75px;
        float: left;

    }
    .clear{
        clear:  both;
    }
    #steps_number span a{
        display: inline-block;
        position: relative;
        padding-top: 25px;
        width: 100px;
        height: 50px;
        text-decoration: none;
        font-size: large;
        font-weight: bold;
        color: white;
        background: #c4d52b;
        border-radius: 5px;
        -moz-border-radius: 5px;
        -webkit-border-radius: 5px;

    }
    #steps_number span a.current{
        background: #3498db;
    }
    #steps-content{
        overflow: hidden;
        height: 500px; 
        margin-top: 5px;
        border: solid #CCC 1px;
        border-radius: 5px;
        -moz-border-radius: 5px;
        -webkit-border-radius: 5px;
       
    }
    #steps-content div#step1, #steps-content div#step2, #steps-content div#step3{
        width: 99%;
        float: left;
        height: 497px;
         padding: 1px 3px;
    }
    #steps_number #bar{
        height: 10px;
        position: relative;
        top:40px;
        margin:0px 16%; 
        background: #c4d52b;
    }
    #steps_number #bar div{
        height: 10px;
        width: 0px;
        background: #3498db;
    }
 #liste_menu{
        margin-top: 5px;
        margin-left: 2px;
        width: 19%;
        height: 80%;
        float: left;
        background: #002166;
        display: inline-block;
    }
    #liste_menu ul{
         list-style: none;
         margin: 0;
    }
    
      #liste_menu ul li{
          height: 40px;
          margin-top: 5px;
          background: #c4d52b;
          border-radius: 5px;
          -moz-border-radius: 5px;
          -webkit-border-radius: 5px; 
          text-align: left;
          padding-left: 4px;
    }
    #liste_menu ul li a{
        text-decoration: none;
        color:white;
        height: 40px;
        display: table-cell;
        vertical-align: middle 
    }
    #uploader_att{
         margin-top: 5px;
        width: 80%;
        height: 80%;
       
        display: inline-block;
    }
    #error_zone{
        text-align: left;
        padding: 2px 5px;
    }
</style>
<div class="mws-panel grid_8">
    <div class="mws-panel-header">
        <span><i class="icon-magic"></i>Création d'u nouveau projet</span>
    </div>
    <div class="mws-panel-body no-padding">
        <div id="creation_steps">
            <div id="steps_number">
                <div id="bar">
                    <div ></div>
                </div>
                <span  ><a href="#step1" class="current" >Etape 1</a></span>
                <span ><a href="#step2" >Etape 2</a></span>
                <span  ><a href="#step3" >Etape 3</a></span>
            </div>
            <div class="clear"></div>

            <div id="steps-content">
            <div id="error_zone">
            </div>
                <div id="step1">
                    

                    <h2>Upload des Resources SVG</h2>
                   <?php echo form_open_multipart(base_url('project/upload_resources'), array('id'=>'form-upload-svg' ,'class'=>'mws-form')); ?>
                    <!--<form class="mws-form" action="<?= base_url('projet/upload_resources')?>" id="">-->
                        <div class="mws-form-inline">
                            <div class="mws-form-row">
                                <label class="mws-form-label">Nom du projet</label>
                                <div class="mws-form-item">
                                    <input type="text" name="projname" class="large">
                                </div>
                            </div>
                            <div class="mws-form-row">
                                <label class="mws-form-label">Resource (zip)</label>
                                <div class="mws-form-item">
                                    <input type="file" name="resfile" >
                                </div>
                            </div>
                        </div>
                    </form>
                    <div class="mws-button-row">
                        <button type="button" class="btn" disabled="disabled">Précedent</button>
                        <button type="button" class="btn" id="next_step1">Suivant</button>
                    </div>
                    
                </div>
               
                 <div id="step2">
                     <div class="mws-panel-header">
                                    <span><i class="icon-upload"></i> File Uploader</span>
                                </div>
                    <div id="liste_menu">
                       
                    </div>
                    <div id="uploader_att">
                     <!--  Start of upload pluging -->
                            <?php css('plugins/plupload/jquery.plupload.queue'); ?>

                            <div class="mws-panel grid_8">
                               
                                <div class="mws-panel-body no-padding">
                                    <div id="uploader">
                                        <p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
                                    </div>
                                </div>
                            </div>
                     </div>
                       <!--  End upload pluging -->
                  <div class="mws-button-row">
                        <button type="button" class="btn" disabled="disabled">Précedent</button>
                        <button type="button" class="btn" id="next_step1">Suivant</button>

                    </div>
                </div>
               
                
                <div id="step3">
                    <h1>Step 3</h1>
                </div>
            </div>
        </div>
    </div>
</div>

<div style="display: none;">

    <form action="<?= base_url('project/upload_resources') ?>" method="post" id="uploadform" enctype="multipart/form-data">
        <input type="file" name="resfile" id='resfile' />  
        <input type="submit" id="submit_upload" />
    </form>
</div>
<?php
js('js/libs/jquery-1.8.3.min')
?>
<script>
jQuery(document ).ready(function()
{
    var current_step = "#step1"
    $('#steps_number span a').click(function(event){
        event.preventDefault();
        var step = $(this).attr('href');
        if(step != current_step)
            $(current_step).hide('slow');
        current_step =step;
        $(step).show('slow');
        return false;
    });
    function goto_setp(num)
    {
        var step = '#step'+num;
       if ( step != current_step )
            $(current_step).hide('slow');
            $current_step = step
            $(step).show('slow');
    }
   
    $('#next_step1').click(function(){
        var error = null;
        
        if( $('input[name="projname"]').val() == null ||  jQuery.trim($('input[name="projname"]').val() ) == '' )
        {            
            error = '<div class="mws-form-message error">';
            error += "Les champ suivant ne peuvent pas être vide ! ";
            error +="<ul>";
            error +="<li>"+'Nom du project</li>';
            $('input[name="projname"]').addClass('error');
        }
        else
        {
           $('input[name="projname"]').removeClass('error'); 
        }
        
        if( $('input[name="resfile"]').val() == null || $('input[name="resfile"]').val() == '' )
        {
            if(error == null)
            {
                error = '<div class="mws-form-message error">';
                error += "Les champ suivant ne peuvent pas être vide ! ";
            }
            error +="<li>Resource (zip)</li>";
            error +="<ul></div>";
            
        }
        if(error != null)
        {
            $('#error_zone').html(error);
            return false;
        }
        else 
        {
              $('#error_zone').html('');
        }
        $('#form-upload-svg').submit();
    });
    
   

    $('#form-upload-svg').ajaxForm(
          {
                beforeSend: function() 
                {

                },
                uploadProgress: function(event, position, total, percentComplete) 
                {
                       
                },
                success: function(data) 
                {
                 var rep = JSON.parse(data);
                  
                 var success = rep.success;
                 if( success == 1)
                 {
                     var list = rep.list;
                     $('#liste_menu').html(list);
                     $('a[href="#step2"]').addClass('current');
                     $('#bar div').css('width' ,'50%');
                    goto_setp(2);
                     
                 }
                 else
                 {  
                     if(rep.error == "CAN_NOT_CREATE_DIR")
                     {
                         alert('Project non crée, avec le nom '+$('#projname').val()+'!\n Veillez saisir un autre nom!');
                         return;
                     }
                    if(rep.error == "CAN_NOT_EXTRACT_ARCHIVE")
                    {
                       alert('Le fichier zip que vous avez uploder n\'a pas pu être extrait !'); 
                       return;
                    }
                 }
                },
                complete: function(xhr) {
                       // status.html(xhr.responseText); this will show upload fiel details
                }
           }); 

        }); 
        
</script>